iT邦幫忙

2021 iThome 鐵人賽

DAY 16
0
自我挑戰組

Vue.js系列 第 16

API

  • 分享至 

  • xImage
  •  

今天先來看一段MuleSoft公司介紹API的影片吧!

從影片中我們能夠很清楚的知道API其實就是扮演著服務生的腳色,它會在應用程式和資料庫以及我們使用的裝置中來回穿梭著,它會去幫我們傳送資料和建立連結,接下來回到網路世界,我們都知道我們開啟的網頁會分成前端和後端,而前端就像是我們打開網頁看到的畫面,後端則是負責去做資料的運算和儲存,那麼前端和後端又是怎麼連接起來的呢?那就是透過我們常聽到的API

API(Application Programming Interface, 應用程式介面):簡單來說它就是讓兩個應用程式透過一個媒介去做溝通,那個媒介就是API

現在我們已經知道API是一個前後端溝通的橋樑了!那什麼又是Restful API呢?

Restful API它不是一個協定,而是一種設計風格,它常和JSON、HTML、HTTP(GET、POST、PUT、DELETE)一起使用

接下來我們利用RedHat公司的說明來介紹Restful API的特色吧!

In order for an API to be considered RESTful, it has to conform to these criteria:

  • A client-server architecture made up of clients, servers, and resources, with requests managed through HTTP.

這裡簡單來說就是前端跟後端要資料

  • Stateless client-server communication, meaning no client information is stored between get requests and each request is separate and unconnected.

這裡的無狀態指的是它不會去記錄client端的資訊

  • Cacheable data that streamlines client-server interactions.

Cacheable指的是當前端去跟後端要資料時,後端會將整包資料丟給前端,而且它的資料是可以暫存的,這樣做的好處是可以提升網路效率

  • A uniform interface between components so that information is transferred in a standard form.

統一介面就像是我們在使用開放式資料時,當我們取得的API時通常會看到資料放在一個JSON的格式中


上一篇
npm
下一篇
postman
系列文
Vue.js30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言